#include "sdlengine.hpp"
using namespace sdl_engine;
using namespace unit_test;

int main([[ maybe_unused ]] int argc,
         [[ maybe_unused ]] char** argv) {
    unittest.AddTest([](){
        std::vector<int> a{1, 2, 3, 4};
        auto cpa = a;
        LinearForeach<int>(a, [](int& elem){ elem ++; });
        for (size_t i = 0; i < a.size(); i++) {
            TEST_TRUE(a[i] == cpa[i] + 1);
        }

        std::vector<std::vector<int>> b{{1, 2}, {3}, {4, 5, 6}};
        auto cpb = b;
        LinearForeach<int>(b, [](int& elem){ elem *= 2; });
        for (size_t i = 0; i < b.size(); i++) {
            for (size_t j = 0; j < b[i].size(); j++) {
                TEST_TRUE(b[i][j] == cpb[i][j] * 2);
            }
        }

        std::vector<std::list<float>> c{{1.2, 3.4},
                                        {5.6, 7.8, 9}};
        auto cpc = c;
        LinearForeach<float>(c, [](float& elem){ elem *= 2; });
        for (size_t i = 0; i < c.size(); i++) {
            auto it1 = c[i].begin();
            auto it2 = cpc[i].begin();
            while (it1 != c[i].end()) {
                TEST_TRUE(*(it1 ++) == *(it2 ++) * 2);
            }
        }
    });

    unittest.RunTests();
    return 0;
}
